{include file="public/header" /}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}

<style type="text/css">
    #des, #des input {
        width: 40px;
        text-align: center;
    }

    #id {
        width: 78px;
    }

    .bs-checkbox {
        width: 36px;
        height: 40px
    }

    .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
        margin-left: 0px;
        margin-top: 0px
    }

    #title span {
        float: right;
    }

    .asdlkjasd {
        background: #1ab394;
        color: #fff
    }
</style>

<body class="gray-bg">
<div class="wrapper wrapper-content {:config('adminClass.main')}">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
            {include file="public/topsection"}
            <div class="row row-lg">
                <div class="col-sm-12">
                    {eq name="nothead" value="0"}
                    <div class="fixed-table-toolbar">
                        <a class="btn btn-default btn-outline {present name='types'}{eq name='types' value='1'}asdlkjasd{/eq}{else /}asdlkjasd{/present}"
                            href="{:url('certification',['types'=>'1'])}{present name='status'}/status/{$status}{/present}">实名</a>
                        <!-- <a class="btn btn-default btn-outline {present name='types'}{eq name='types' value='2'}asdlkjasd{/eq}{/present}"
                           href="{:url('certification',['types'=>'2'])}{present name='status'}/status/{$status}{/present}">学历</a>
                        <a class="btn btn-default btn-outline {present name='types'}{eq name='types' value='3'}asdlkjasd{/eq}{/present}"
                           href="{:url('certification',['types'=>'3'])}{present name='status'}/status/{$status}{/present}">车辆</a>
                        <a class="btn btn-default btn-outline {present name='types'}{eq name='types' value='4'}asdlkjasd{/eq}{/present}"
                           href="{:url('certification',['types'=>'4'])}{present name='status'}/status/{$status}{/present}">房产</a>
                        <a class="btn btn-default btn-outline {present name='types'}{eq name='types' value='6'}asdlkjasd{/eq}{/present}"
                           href="{:url('certification',['types'=>'6'])}{present name='status'}/status/{$status}{/present}">收入</a>
                        <a class="btn btn-default btn-outline {present name='types'}{eq name='types' value='7'}asdlkjasd{/eq}{/present}"
                           href="{:url('certification',['types'=>'7'])}{present name='status'}/status/{$status}{/present}">婚姻</a> -->
                        <a class="btn btn-default btn-outline {present name='types'}{eq name='types' value='5'}asdlkjasd{/eq}{/present}"
                           href="{:url('certification',['types'=>'5'])}{present name='status'}/status/{$status}{/present}">语音签名</a>
                    </div>
                    <div class="fixed-table-toolbar">
                        <a class="btn btn-default btn-outline {present name='status'}{else /}asdlkjasd{/present}"
                            href="{:url('certification')}{present name='types'}/types/{$types}{/present}">所有</a>
                        <a class="btn btn-default btn-outline {present name='status'}{eq name='status' value='0'}asdlkjasd{/eq}{/present}"
                            href="{:url('certification',['status'=>'0'])}{present name='types'}/types/{$types}{/present}">审核</a>
                        <a class="btn btn-default btn-outline {present name='status'}{eq name='status' value='1'}asdlkjasd{/eq}{/present}"
                            href="{:url('certification',['status'=>'1'])}{present name='types'}/types/{$types}{/present}">通过</a>
                        <a class="btn btn-default btn-outline {present name='status'}{eq name='status' value='-1'}asdlkjasd{/eq}{/present}"
                           href="{:url('certification',['status'=>'-1'])}{present name='types'}/types/{$types}{/present}">拒绝</a>
                           {eq name='types' value='1'}
                        <a style="margin-left: 57px" class="btn btn-default btn-outline {eq name='longname' value='1'}asdlkjasd{/eq}"
                           href="{:url('certification',['longname'=>$longname?0:1])}{present name='types'}/types/{$types}{/present}{present name='status'}/status/{$status}{/present}">三个字以上</a>
                           {/eq}
                    </div>
                    <div style="display:block;clear: both;"></div>
                    <div class="fixed-table-toolbar">
                        <form method="get" action="" style="display: flex;">
                            <div class="pull-left search" style="display: flex;">
                                <div class="columns columns-right btn-group pull-left">
                                    <select class="form-control" name="search">
                                        <option value="id" {php}if(input(
                                        '?param.search')){if(input('param.search')=='id'){echo "selected";}
                                        }{/php}>用户ID</option>
                                        <option value="phone" {php}if(input(
                                        '?param.search')){if(input('param.search')=='phone'){echo "selected";}
                                        }{/php}>手机</option>
                                        <option value="name" {php}if(input(
                                        '?param.search')){if(input('param.search')=='name'){echo "selected";}
                                        }{/php}>昵称</option>

                                        {present name='types'}
                                        {eq name='types' value='1'}
                                        <option value="data" {php}if(input(
                                        '?param.search')){if(input('param.search')=='data'){echo "selected";}
                                        }{/php}>身份证号码</option>
                                        {/eq}
                                        {/present}
                                    </select>
                                </div>

                                <div class="pull-right search">
                                    <input class="form-control input-outline" type="text"
                                           {php}
                                           if(input('?param.name')){
                                    if(input('param.name')){
                                    echo "value='".input('name')."'";
                                    }

                                    }
                                    {/php}
                                    name="name" placeholder="搜索">
                                </div>

                                <div class="pull-right search">
                                    <button style="border-radius:0px; border:1px solid #e5e6e7; border-left:0px"
                                            class="btn btn-default btn-outline" type="submit">搜索
                                    </button>
                                </div>

                                {php}
                                if(input('?param.name')){
                                {/php}
                                <div class="pull-right search">
                                    <a class="btn btn-w-m btn-link" href="{:url('certification')}">返回列表</a>
                                </div>
                                {php}
                                }
                                {/php}
                            </div>
                        </form>
                    </div>
                    {/eq}
                    <div class="example">
                        <form class="form-horizontal" method="post">
                            <table data-toggle="table">
                                <thead>
                                <tr>
                                    <th data-align="center">类型</th>
                                    <th data-align="center">用户</th>
                                    {present name='types'}
                                        {neq name='types' value='5'}
                                            {eq name='types' value='1'}
                                            <th data-align="center">身份证信息</th>
                                            <th data-align="center">真人认证图</th>
                                            {/eq}
                                            <th data-align="center">正面图</th>
                                            <th data-align="center">反面图</th>
                                        {else /}
                                            <th data-align="center">语音</th>
                                        {/neq}
                                    {else /}
                                        <th data-align="center">正面图</th>
                                        <th data-align="center">反面图</th>
                                    {/present}
                                    <th data-align="center">理由</th>
                                    <th data-align="center">状态</th>
                                    <th data-align="center">创建时间</th>
                                    <th data-align="center">更新时间</th>
                                    <th data-align="center">审核时间</th>
                                    <th data-align="center">审核人</th>
                                    <th data-align="center">管理</th>
                                </tr>
                                </thead>
                                <tbody id="form">
                                {volist name="data" id="v"}
                                <tr id="id{$v.id}" class="class">
                                    <td>
                                        {switch name="v.types"}
                                        {case value="1"}实名{/case}
                                        {case value="2"}学历{/case}
                                        {case value="3"}车辆{/case}
                                        {case value="4"}房产{/case}
                                        {case value="5"}语音签名{/case}
                                        {/switch}
                                    </td>
                                    <td>
                                        <a onclick="member('{$v.user_id}')" style="color:#40BCF7">{$v.name}</a>
                                        <br/>({$v.user_id})
                                        <br/>({$v.sex})({$v.age})({$v.province}{$v.city})
                                        <br/>{if condition="$v.types == 1 && (!$v.data || !$v.data2)"}<span style="color: red;cursor: pointer;">未填身份证</span>{/if}
                                        {if condition="$v.data_cover"}
                                        <br/><span style="color: red;cursor: pointer;" onclick="cover('{$v.data_cover}')">查看已存在的实名</span>
                                        {/if}
                                        {eq name="$v.tip_reason" value="1"}
                                        <br/><span style="color: #fa0;">真人认证图与身份证照片不符</span>
                                        {/eq}

                                        {eq name="$v.types" value="2"}
                                        <br/><span style="color: #f20;">{$v.education_background}</span>
                                        {/eq}
                                        {eq name="$v.types" value="7"}
                                        <br/><span style="color: #f20;">{$v.emotion}</span>
                                        {/eq}
                                        {eq name="$v.types" value="4"}
                                        <br/><span style="color: #f20;">{$v.is_house_purchase}</span>
                                        {/eq}
                                        {eq name="$v.types" value="6"}
                                        <br/><span style="color: #f20;">{$v.monthly_salary}</span>
                                        {/eq}
                                        {eq name="$v.types" value="3"}
                                        <br/><span style="color: #f20;">{$v.is_car_purchase}</span>
                                        {/eq}
                                    </td>

                                    {present name='types'}
                                        {neq name='types' value='5'}
                                            {eq name='types' value='1'}
                                            <td>
                                                <input type="text" class="form-control idcardname" placeholder="姓名" onblur="idcardname('{$v.id}')" value="{$v.data2}" name="data2">
                                                <input type="text" class="form-control idcard" placeholder="身份证" onblur="idcard('{$v.id}')" value="{$v.data}" name="data">
                                            </td>
                                            <td>
                                              <!-- ... 已有代码 ... -->
{php}
// 检查 $v.authpic 是否存在
if (isset($v['authpic']) && $v['authpic'] !== '') {
    // 判断 URL 是否包含协议头
    $authpicUrl = strpos($v['authpic'], 'http') === 0 ? $v['authpic'] : '__ROOT__' . $v['authpic'];
    // 对 URL 进行转义处理
    $escapedAuthpicUrl = htmlspecialchars($authpicUrl, ENT_QUOTES, 'UTF-8');
} else {
    $escapedAuthpicUrl = '';
}
{/php}
{if condition="$escapedAuthpicUrl"}
<a href="{$escapedAuthpicUrl}" title="{$v.authpic}" target="_blank" onclick="lookBigImg('{$escapedAuthpicUrl}')">
    <img style="max-width:120px" src="{$escapedAuthpicUrl}"/>
</a>
{/if}
<!-- ... 已有代码 ... -->
                                            </td>
                                            {/eq}
                                            <td>
                                              <!-- ... 已有代码 ... -->
{php}
// 检查 $v.image_front 是否存在且不为空字符串
if (isset($v['image_front']) && $v['image_front'] !== '') {
    // 判断 URL 是否包含协议头
    $imageFrontUrl = strpos($v['image_front'], 'http') === 0 ? $v['image_front'] : '__ROOT__' . $v['image_front'];
    // 对 URL 进行转义处理
    $escapedImageFrontUrl = htmlspecialchars($imageFrontUrl, ENT_QUOTES, 'UTF-8');
} else {
    $escapedImageFrontUrl = '';
}
{/php}
{if condition="$escapedImageFrontUrl"}

<a href="{$escapedImageFrontUrl}" title="{$v.name}" style="color: #0c4eff" target="_blank" onclick="lookBigImgs('{$escapedImageFrontUrl}','{$v.id}')">
    点击查看
</a>
{/if}
<!-- ... 已有代码 ... -->
                                            </td>
                                            <td>
                                                <!-- ... 已有代码 ... -->
{php}
// 检查 $v.image_behind 是否存在且不为空字符串
if (isset($v['image_behind']) && $v['image_behind'] !== '') {
    // 判断 URL 是否包含协议头
    $imageBehindUrl = strpos($v['image_behind'], 'http') === 0 ? $v['image_behind'] : '__ROOT__' . $v['image_behind'];
    // 对 URL 进行转义处理
    $escapedImageBehindUrl = htmlspecialchars($imageBehindUrl, ENT_QUOTES, 'UTF-8');
} else {
    $escapedImageBehindUrl = '';
}
{/php}
{if condition="$escapedImageBehindUrl"}
<a href="{$escapedImageBehindUrl}" title="{$v.name}" target="_blank"  onclick="lookBigImg('{$escapedImageBehindUrl}')">
    <img style="max-width:250px" src="{$escapedImageBehindUrl}"/>
</a>
{/if}
<!-- ... 已有代码 ... -->
                                            </td>
                                        {else /}
                                            <td>
                                                <audio src="{:strpos($v.image_front, 'http')===false?'__ROOT__':''}{$v.image_front}" controls="controls"></audio>
                                            </td>
                                        {/neq}
                                        {else /}
                                            <td>
                                                <a href="{:strpos($v.image_front, 'http')===false?'__ROOT__':''}{$v.image_front}" title="{$v.name}" target="_blank">
                                                    <img style="width:40px;height:40px;" src="{:strpos($v.image_front, 'http')===false?'__ROOT__':''}{$v.image_front}"/>
                                                </a>
                                            </td>
                                            <td>
                                                {if condition='$v.image_behind'}
                                                <a href="{:strpos($v.image_behind, 'http')===false?'__ROOT__':''}{$v.image_behind}" title="{$v.name}" target="_blank">
                                                    <img style="width:40px;height:40px;" src="{:strpos($v.image_behind, 'http')===false?'__ROOT__':''}{$v.image_behind}"/>
                                                </a>
                                                {/if}
                                            </td>
                                    {/present}
                                    <td>{$v.reason}</td>
                                    <td>
                                        {switch name="v.status"}
                                            {case value="-1"}<span class="btn btn-primary btn-xs" style="background-color:#585858;border-color:#585858">拒&nbsp;&nbsp;&nbsp;绝</span>{/case}
                                            {case value="0"}<span class="btn btn-default btn-xs">审&nbsp;&nbsp;&nbsp;核</span>{/case}
                                            {case value="1"}<span class="btn btn-primary btn-xs">通&nbsp;&nbsp;&nbsp;过</span>{/case}
                                        {/switch}
                                    </td>
                                    <td>
                                        <span {if condition="date('Ymd')==date('Ymd',$v.create_time)"}style="color: #ed5565"{/if}>{:date('Y-m-d H:i', $v.create_time)}</span>
                                    </td>
                                    <td>
                                        <span {if condition="date('Ymd')==date('Ymd',$v.update_time)"}style="color: #ed5565"{/if}>{:date('Y-m-d H:i', $v.update_time)}</span>
                                    </td>
                                    <td>
                                        <span>{neq name="$v.shenhe_time" value="0"}{:date('Y-m-d H:i:s', $v.shenhe_time)}{/neq}</span>
                                    </td>
                                    <td>
                                        <span>{:_getAdminName($v.shenhe_admin_id)}</span>
                                    </td>
                                    <td>
                                        <div class="btn-group">
                                            <div data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">
                                                操作 <span class="caret"></span>
                                            </div>
                                            <ul class="dropdown-menu">
                                                <li><a onClick="reasonRecords({$v.id})">驳回历史记录</a></li>
                                                <li class="divider"></li>
                                                <li><a onClick="certification({$v.id},-1)">拒绝</a></li>
                                                <li><a onClick="certification({$v.id},0)">审核</a></li>
                                                <li><a onClick="certification({$v.id},1)">通过</a></li>
                                                <li class="divider"></li>
                                                <li><a onClick="del({$v.id})" style="color:red">删除</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </td>
                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </form>
                    </div>
                </div>
            </div>
            <hr>
            <div class="row row-lg">
                <div class="col-sm-12 pages">{$page}</div>
            </div>
        </div>
    </div>
</div>

{include file="public/footer" /}
{load href="__PLUGINS__iCheck/icheck.min.js"}
{load href="__PLUGINS__iCheck/custom.css"}

<script type="text/javascript">

    $(document).ready(function(){
        $('#desAll').click(function(){
            var des=$(".form-horizontal").serialize();
            ajaxFun("post",'{:url("desAll")}',des,'json',function(ret){
                if(ret){
                    if(ret.ret){
                        self.location.reload();
                    }else{
                        layer.msg(ret.err)
                    }
                }else{
                    swal_msg("错误",ret,"error");
                }
            })
        })

        $('#delidAll').click(function(){
            $('input[type=checkbox]').each(function(){
                var self=$(this);
                if(!self.prop('checked')){
                    self.prop('checked',true);
                }else{
                    self.prop('checked',false);
                }
            });
        })
    });

    // 跳转用户信息
    function member(id)
    {
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
                title :'预览',
                area: ['100%', '100%'],
                type: 2,
                content: '{:url("index")}?search=id&name='+id
            });
        });
    }

    function del(id)
    {
        swal_del(id, "{:url('certificationDel')}")
    }
    function idcard(id){
        var val = $('#id'+id).find('.idcard').val();
        $.ajax({
            type: 'post',
            url: '{:url("idcardenter")}',
            data: {id:id,data:val},
            dataType: 'json',
            success:function(ret){
                if (ret.ret) {
                    layer.msg('设置成功')
                } else {
                    layer.msg(ret.err);
                }
            },
            error:function(err){
                layer.msg(err)
            }
        });
    }
    function idcardname(id){
        var val = $('#id'+id).find('.idcardname').val();
        $.ajax({
            type: 'post',
            url: '{:url("idcardnameenter")}',
            data: {id:id,data:val},
            dataType: 'json',
            success:function(ret){
                if (ret.ret) {
                    layer.msg('设置成功')
                } else {
                    layer.msg(ret.err);
                }
            },
            error:function(err){
                layer.msg(err)
            }
        });
    }

    function certification(id,status)
    {
        if (status == -1) {
            layer.prompt({title: '拒绝原因', formType: 2}, function(text, index){
                var reason = text;

                ajaxFun("post","{:url('certificationEdit')}",{id:id,status:status,reason:reason},'json',function(ret){
                    if(ret){
                        if(ret.ret){
                            layer.msg(ret.ret)
                            window.location.reload()
                        }else{
                            layer.msg(ret.err)
                        }
                    }else{
                        swal_msg("错误",ret,"error");
                    }
                })
            });
        } else {
            ajaxFun("post","{:url('certificationEdit')}",{id:id,status:status},'json',function(ret){
                if(ret){
                    if(ret.ret){
                        layer.msg(ret.ret)
                        window.location.reload()
                    }else{
                        layer.msg(ret.err)
                    }
                }else{
                    swal_msg("错误",ret,"error");
                }
            })
        }
    }

    function watch(id)
    {
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
                title :'预览',
                area: ['100%', '100%'],
                type: 2,
                content: '{:url("certificationWatch")}?id='+id
            });
        });
    }
    function reasonRecords(id)
    {
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
                title :'驳回历史记录',
                area: ['60%', '70%'],
                type: 2,
                content: '{:url("certificationWatch")}?id='+id
            });
        });
    }

    function cover(idcard)
    {
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
                title :'预览',
                area: ['100%', '100%'],
                type: 2,
                content: '{:url("member/certification")}?nothead=1&search=data&name='+idcard
            });
        });
    }
</script>
